package com.example.springbootsfzy.service.liujinping;

import com.example.springbootsfzy.domain.Announcements;
import com.example.springbootsfzy.mapper.AnnouncementsMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AnnouncementsService {
    @Autowired
    private AnnouncementsMapper announcementsMapper;

    public int addAnnouncements(Announcements announcements) {
        return announcementsMapper.insert(announcements);
    }

    public int deleteAnnouncements(Long id) {
        return announcementsMapper.deleteByPrimaryKey(id);
    }
    public int  updateAnnouncementsActive(Announcements announcements){
        return announcementsMapper.updateByPrimaryKeySelective(announcements);
    }
    public int updateAnnouncements(Announcements announcements) {
        return announcementsMapper.updateByPrimaryKey(announcements);
    }
    public List<Announcements> selectByConsultantId(int consultantId, int pageNum, int pageSize) {
        int offset = (pageNum - 1) * pageSize;
        return announcementsMapper.selectByConsultantId(consultantId, offset, pageSize);
    }

    public Announcements getAnnouncements(Long id) {
        return announcementsMapper.selectByPrimaryKey(id);
    }

    public List<Announcements> getAllAnnouncements() {
        return announcementsMapper.selectAll();
    }
}
